<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8" />
		<title>v-if与v-show</title>
		<script src="https://unpkg.com/vue@next"></script>
		<script src="https://unpkg.com/axios/dist/axios.min.js"></script>
	</head>
	<body>
		<div id="app">
			{{ info }}

		</div>
	</body>
	<script>
		//view model
		const app = {
			data() {
				return {
					info: 'Ajax 测试!!'
				}
			},
			mounted() {
				/*
				axios
					.get('http://www.runoob.com/try/ajax/json_demo.json')
					.then(response => (this.info = response))
					.catch(function(error) { // 请求失败处理
						console.log(error);
					});
					*/
                /*
				axios
					.post('http://www.runoob.com/try/ajax/demo_axios_post.php')
					.then(response => (this.info = response.data))
					.catch(function(error) { // 请求失败处理
						console.log(error);
					});
				*/
			   
			    /*
				axios({
				  method: 'post',
				  url: 'http://www.runoob.com/try/ajax/demo_axios_post.php',
				}).then(function(response) {
					console.log("data = ", response.data);
                });
				*/
			   /*
			   axios({
			     method: 'post',
			     url: 'http://go.jinying.com/ajax_x/interface/new/index_v7',
			     data: {
			       company_no: '0101',
			       gemart_company_no: '0101'
			     }
			   }).then((response) => {
				   console.log("data = ", response.data);
			   });
			   */
			  
			  let info = {company_no: '0101',gemart_company_no: '0101'}
			  axios.post('http://go.jinying.com/ajax_x/interface/new/index_v7', {
			      data: info
			  },{
			      headers: {
			          'Access-Control-Allow-Origin':'*',  //解决cors头问题
			          'Access-Control-Allow-Credentials':'true', //解决session问题
			          'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8' //将表单数据传递转化为form-data类型
			      },
			      withCredentials : true
			  }).then(function (response) {
			          var res = response.data;
					  console.log("res = ",res);
			  }).catch(function (error) {
			          alert(error);
			  });
			}
		}

		Vue.createApp(app).mount('#app')
	</script>
</html>
